/************************************************
 * Copyright (c) 2007 ~ 2009, 
 * All rights reserved.
 * Version   : 1.0
 * Author    : lengsh@gmail.com 
 * Date      : 2008.1.2
 ***********************************************/

#ifndef _SCHEDULER_HELPER_H______
#define _SCHEDULER_HELPER_H______

#include <string>
#include <map>
#include <iostream>
#include <pthread.h>
#include <string.h>
#include "Tscheduler.h"
#include "antxdef.h"

using namespace std;
class Helper 
{
	protected:
		static Helper *_instance;
		bool  Startup(const char *filename);
	protected:
		string m_sConfFile;
                Tscheduler *m_oTs;
                string m_atShell;
                string m_shellscript;
                long m_lLasttime;
                int m_iTime_gap;
                int  m_iEvents;
                int m_server_port;
	public:
		static Helper *Instance(const char *conf = NULL);
		static void Release( bool bForce = false);
	protected:
		Helper();
		virtual ~Helper();
		int run_shell(const char *shell);
	public:
		int Update(const char *key, int klen, int flags, time_t expire, const char *data, int dlen);
		int Process(map < int, string > &keys, conn *c);
		int Process(const char *cmd, conn *c);
		int Timer(long time, int gap);
		int Check(void *args);
		char *Stats(char * ext_stats);

};


#endif 

